export type EntitySpec = {
  key: string;
  name: string;
  type?: string;
  width?: number;
}

export type EntityViewMode = "c" | "r" | "u";

export type EntityTypeSpec<T> = {
  [P in keyof T]: EntitySpec
}

export type KeysEnum<T> = { [P in keyof Required<T>]: true };

//方法1 use KeysEnum trick to make different type to type 'true'
const EntitySpecKeysEnum: KeysEnum<EntitySpec>= {
  key: true,
  name: true,
  type: true,
  width: true,
}

const keysOfEntitySpecKey = Object.keys(EntitySpecKeysEnum)

// 方法2
export const EntitySpecAllKeys = ['key', 'name'] as const;
type EntitySpecKeysTuple = typeof EntitySpecAllKeys;
type EntitySpecKeys = EntitySpecKeysTuple[number];
export type AppApiAsListItem = Pick<EntitySpec, EntitySpecKeys>;